package XML;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.IOException;

public class GetXMLDataDemo {



    static File file = new File("D:\\GitHOME\\information\\text.xml");



    public static void get(int l) {

        DocumentBuilder newDocumentBuilder = null;
        try {
            newDocumentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        }

        Document doc = null;
        try {
            doc = newDocumentBuilder.parse(file);
        } catch (SAXException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        Element root = doc.getDocumentElement();


        NodeList personList = root.getElementsByTagName("spot");

       /* System.out.println("请输入一个整数：");
        Scanner scan = new Scanner(System.in);
        String j=scan.next();*/


       Node item = personList.item(l);
       //    m = item.getTextContent();
      //  System.out.println(item.getTextContent());



        //Element element = (Element)item;

        //NodeList nameList = element.getElementsByTagName("name");

     //   System.out.println(nameList.item(i).getTextContent());

    }



}

